﻿namespace Reap.AzureResource.Web {
	using System;
	using System.Collections.Generic;
	using System.Data.Entity.Core.Mapping;
	using System.Data.Entity.Core.Metadata.Edm;
	using System.Data.Entity.Core.Objects;
	using System.Data.Entity.Infrastructure;
	using System.Web;
	using System.Web.Mvc;
	using System.Web.Optimization;
	using System.Web.Routing;
	using System.Web.Security;

	using Reap.AzureResource.Model.Models;
	using Reap.Common.Runtime;

	using WebSite;

	public class MvcApplication:HttpApplication {

		protected void Application_Start() {
			DependencyResolver.SetResolver(new NinjectResolver(EngineContext.Current,
				DependencyResolver.Current));
			AreaRegistration.RegisterAllAreas();
			RouteConfig.RegisterRoutes(RouteTable.Routes);
			BundleConfig.RegisterBundles(BundleTable.Bundles);
				#region	给EntityFramework 预热加快处理速度

			using (var dbcontext = new AzureResourceContext())
			{
				ObjectContext objectContext = ((IObjectContextAdapter) dbcontext).ObjectContext;
				var mappingCollection =
					(StorageMappingItemCollection) objectContext.MetadataWorkspace.GetItemCollection(DataSpace.CSSpace);
				mappingCollection.GenerateViews(new List<EdmSchemaError>());
			}

			#endregion
		}



	}
}